#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
 @file name: serializers.py
 @desc:
 @author: xu wang
 @mail: jason_wangxu@163.com
 @date: 2025/1/6 20:33
"""
from rest_framework import serializers
from rest_framework.serializers import ModelSerializer

from BugManage.models import BugManage, BugHandle


class BugHandleSerializer(ModelSerializer):
    class Meta:
        model = BugHandle
        fields = "__all__"


class BugManageSerializer(ModelSerializer):
    interface_url = serializers.StringRelatedField(read_only=True, source="interface")
    handle = BugHandleSerializer(many=True, source="bughandle_set")

    class Meta:
        model = BugManage
        fields = "__all__"


class BugManageListSerializer(ModelSerializer):
    interface_url = serializers.StringRelatedField(read_only=True, source="interface")

    class Meta:
        model = BugManage
        fields = ["id", "interface_url", "desc", "create_time", "status", "user"]
